package com.fengye.eshop.service.controller;

import com.fengye.eshop.api.ProductApi;
import com.fengye.eshop.api.UserApi;
import com.fengye.eshop.service.config.ConfigProperties;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author fengyexjtu@126.com
 * @date 2022年05月14日 5:01 PM
 */
@RestController
public class OrderController {

    @Resource
    ProductApi productApi;

    @Resource
    UserApi userApi;

    @Resource
    private ConfigProperties configProperties;

    @GetMapping("/order/config")
    public Object getConfig() {
        return configProperties.toString();
    }

    @GetMapping("/order/info")
    public Object getOrderInfo() {
        String product = (String) productApi.getProductInfoById("productId_xxx_xxx_001");
        String user = (String) userApi.getUserInfoById("userId_xxx_xxx_001");
        return "获取到订单信息: orderId = " + configProperties.getOrder4() +
                ",用户信息为:" + user +
                ",商品信息为:" + product;
    }
}
